<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Returns the sub-elements of the current element</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="simplexmliterator.current.html">« SimpleXMLIterator::current</a></li>
      <li style="float: right;"><a href="simplexmliterator.haschildren.html">SimpleXMLIterator::hasChildren »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.simplexmliterator.html">SimpleXMLIterator</a></li>
    <li>Returns the sub-elements of the current element</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="simplexmliterator.getchildren" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">SimpleXMLIterator::getChildren</h1>
  <p class="verinfo">(PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">SimpleXMLIterator::getChildren</span> &mdash; <span class="dc-title">Returns the sub-elements of the current element</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-simplexmliterator.getchildren-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>SimpleXMLIterator::getChildren</strong></span>(): <span class="type"><a href="class.simplexmliterator.html" class="type SimpleXMLIterator">SimpleXMLIterator</a></span></div>

  <p class="para rdfs-comment">
   This method returns a <span class="classname"><a href="class.simplexmliterator.html" class="classname">SimpleXMLIterator</a></span> object
   containing sub-elements of the current <span class="classname"><a href="class.simplexmliterator.html" class="classname">SimpleXMLIterator</a></span>
   element.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-simplexmliterator.getchildren-parameters">
  <h3 class="title">参数</h3>
  <p class="para">此函数没有参数。</p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-simplexmliterator.getchildren-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns a <span class="classname"><a href="class.simplexmliterator.html" class="classname">SimpleXMLIterator</a></span> object containing
   the sub-elements of the current element.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-simplexmliterator.getchildren-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-5467">
    <p><strong>示例 #1 Return the sub-elements of the current element</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$xml&nbsp;</span><span style="color: #007700">=&nbsp;&lt;&lt;&lt;XML<br /></span><span style="color: #DD0000">&lt;books&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;book&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;title&gt;PHP&nbsp;Basics&lt;/title&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;author&gt;Jim&nbsp;Smith&lt;/author&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;/book&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;book&gt;XML&nbsp;basics&lt;/book&gt;<br />&lt;/books&gt;<br /></span><span style="color: #007700">XML;<br /><br /></span><span style="color: #0000BB">$xmlIterator&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">SimpleXMLIterator</span><span style="color: #007700">(</span><span style="color: #0000BB">$xml</span><span style="color: #007700">);<br />for(&nbsp;</span><span style="color: #0000BB">$xmlIterator</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">rewind</span><span style="color: #007700">();&nbsp;</span><span style="color: #0000BB">$xmlIterator</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">valid</span><span style="color: #007700">();&nbsp;</span><span style="color: #0000BB">$xmlIterator</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">next</span><span style="color: #007700">()&nbsp;)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;foreach(</span><span style="color: #0000BB">$xmlIterator</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getChildren</span><span style="color: #007700">()&nbsp;as&nbsp;</span><span style="color: #0000BB">$name&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$data</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"The&nbsp;</span><span style="color: #0000BB">$name</span><span style="color: #DD0000">&nbsp;is&nbsp;'</span><span style="color: #0000BB">$data</span><span style="color: #DD0000">'&nbsp;from&nbsp;the&nbsp;class&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">get_class</span><span style="color: #007700">(</span><span style="color: #0000BB">$data</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
The title is &#039;PHP Basics&#039; from the class SimpleXMLIterator
The author is &#039;Jim Smith&#039; from the class SimpleXMLIterator
</pre></div>
    </div>
   </div>
  </p>
 </div>


</div></div></div></body></html>